<script>
    var arr1 = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2']
    var arr2 = ['A', 'B', 'C', 'D']

    function concatArr(arr1,arr2){
        const arr=[...arr1]
        let currentIndex=0
        for(let i=0;i<arr2.length;i++){
            const RE=new RegExp(arr2[i])
            while(currentIndex <arr.length){
                ++currentIndex
                if(!RE.test(arr[currentIndex])){
                    arr.splice(currentIndex,0,arr2[i])
                    break;
                }
            }
        }
        return arr
    }
    concatArr(arr1,arr2)
</script>